/*
 * Copyright (c) 2023-2023 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import router from "@ohos.router";
import vibrator from "@ohos.vibrator";

const PUBLIC_DEFAULT_IMAGE = "";
const COL_IMAGE_TEXT = 3;
const COL_TEXT = 4;
const BLOCKHEIGHT_TEXT = 32;
const BLOCKHEIGHT_IMAGE_TEXT = 135;
const COLUMNS_GAP_TEXT = 8;
const COLUMNS_GAP_IMAGE_TEXT = 16;
const ROW_GAP = 16;
const TAG_FONTSIZE = 14;
const DURATION = 500;
const ICON_SIZE = 24;
const IMAGE_DEFAULT = 56;

export var GridEditType;
!function(e){
    e.imageText = "object";
    e.text = "text"
}(GridEditType || (GridEditType = {}));

export var StateType;
!function(e){
    e[e.select=1] = "select";
    e[e.unSelect=0] = "unSelect"
}(StateType || (StateType = {}));

function __Text__blockTextStyle(e = 65) {
    Text.fontColor({
        id: -1,
        type: 10001,
        params: ["sys.color.ohos_id_color_text_primary"],
        bundleName: "",
        moduleName: ""
    });
    Text.backgroundColor({
        id: -1,
        type: 10001,
        params: ["sys.color.ohos_id_color_button_normal"],
        bundleName: "",
        moduleName: ""
    });
    Text.fontSize({
        id: -1,
        type: 10002,
        params: ["sys.float.ohos_id_text_size_button3"],
        bundleName: "",
        moduleName: ""
    });
    Text.maxLines(1);
    Text.textOverflow({ overflow: TextOverflow.Ellipsis });
    Text.height(28);
    Text.width(e);
    Text.textAlign(TextAlign.Center);
    Text.borderRadius(50);
    Text.padding({ top: 8, bottom: 8, left: 12, right: 12 })
}

function __Text__subTitleTextStyle(e = "100%", t = TextAlign.Start) {
    Text.fontColor({
        id: -1,
        type: 10001,
        params: ["sys.color.ohos_id_color_text_secondary"],
        bundleName: "",
        moduleName: ""
    });
    Text.fontSize({
        id: -1,
        type: 10002,
        params: ["sys.float.ohos_id_text_size_sub_title3"],
        bundleName: "",
        moduleName: ""
    });
    Text.fontWeight(FontWeight.Medium);
    Text.textOverflow({ overflow: TextOverflow.Ellipsis });
    Text.textAlign(t);
    Text.width(e);
    Text.margin({
        top: 12,
        left: {
            id: -1,
            type: 10002,
            params: ["sys.float.ohos_id_max_padding_end"],
            bundleName: "",
            moduleName: ""
        },
        bottom: 8,
        right: 4
    })
}

function sortBy() {
    return (e, t) => e.sort - t.sort
}

export class GridEdit extends ViewPU {
    constructor(e, t, i, o = -1) {
        super(e, i, o);
        this.__options = new SynchedPropertyObjectTwoWayPU(t.options, this, "options");
        this.__dataList = new SynchedPropertyObjectTwoWayPU(t.dataList, this, "dataList");
        this.__selected = new ObservedPropertyObjectPU(this.dataList.filter((e => e.state)).sort(sortBy()), this, "selected");
        this.__unSelected = new ObservedPropertyObjectPU(this.dataList.filter((e =>!e.state)).sort(sortBy()), this, "unSelected");
        this.__copySelected = new ObservedPropertyObjectPU(JSON.parse(JSON.stringify(this.selected)), this, "copySelected");
        this.__copyUnSelected = new ObservedPropertyObjectPU(JSON.parse(JSON.stringify(this.unSelected)), this, "copyUnSelected");
        this.__content = new ObservedPropertyObjectPU({
            id: "",
            text: "",
            state: StateType.unSelect,
            sort: 0
        }, this, "content");
        this.__colNum = new ObservedPropertySimplePU(this.options.type === GridEditType.imageText ? 3 : 4, this, "colNum");
        this.__gridComState = new ObservedPropertySimplePU(!1, this, "gridComState");
        this.__areaWidth = new ObservedPropertySimplePU(0, this, "areaWidth");
        this.__blockWidth = new ObservedPropertySimplePU(0, this, "blockWidth");
        this.__blockHeight = new ObservedPropertySimplePU(this.options.type === GridEditType.imageText ? 135 : 32, this, "blockHeight");
        this.__longScale20 = new ObservedPropertySimplePU(1, this, "longScale20");
        this.__longScale09 = new ObservedPropertySimplePU(1, this, "longScale09");
        this.__isStartDrag = new ObservedPropertySimplePU(!1, this, "isStartDrag");
        this.__dragNextID = new ObservedPropertySimplePU(0, this, "dragNextID");
        this.__insterIndex = new ObservedPropertySimplePU(-1, this, "insterIndex");
        this.__editGridDataLength = new ObservedPropertySimplePU(Math.trunc(this.selected.length), this, "editGridDataLength");
        this.__touchDown = new ObservedPropertyObjectPU({
            id: -1,
            type: 10001,
            params: ["sys.color.ohos_id_color_click_effect"],
            bundleName: "",
            moduleName: ""
        }, this, "touchDown");
        this.__touchDownBg = new ObservedPropertyObjectPU({
            id: -1,
            type: 10001,
            params: ["sys.color.ohos_id_color_hover"],
            bundleName: "",
            moduleName: ""
        }, this, "touchDownBg");
        this.__isTouchDown = new ObservedPropertySimplePU(!1, this, "isTouchDown");
        this.__startX = new ObservedPropertySimplePU(0, this, "startX");
        this.__startY = new ObservedPropertySimplePU(0, this, "startY");
        this.__endX = new ObservedPropertySimplePU(0, this, "endX");
        this.__endY = new ObservedPropertySimplePU(0, this, "endY");
        this.__unSelectedIndex = new ObservedPropertySimplePU(0, this, "unSelectedIndex");
        this.__isClickClostBtn = new ObservedPropertySimplePU(!1, this, "isClickClostBtn");
        this.__selectedIndex = new ObservedPropertySimplePU(-1, this, "selectedIndex");
        this.__arraySelectIsChange = new ObservedPropertySimplePU(0, this, "arraySelectIsChange");
        this.__isClickAddBtn = new ObservedPropertySimplePU(!1, this, "isClickAddBtn");
        this.__arrayUnSelectIsChange = new ObservedPropertySimplePU(0, this, "arrayUnSelectIsChange");
        this.__gridHeight = new ObservedPropertySimplePU(0, this, "gridHeight");
        this.__isClickRemoveBtn = new ObservedPropertySimplePU(!1, this, "isClickRemoveBtn");
        this.__isVibrationDone = new ObservedPropertySimplePU(!1, this, "isVibrationDone");
        this.scroller = new Scroller;
        this.setInitiallyProvidedValue(t)
    }

    get options() {
        return this.__options.get()
    }

    set options(e) {
        this.__options.set(e)
    }

    get dataList() {
        return this.__dataList.get()
    }

    set dataList(e) {
        this.__dataList.set(e)
    }

    get selected() {
        return this.__selected.get()
    }

    set selected(e) {
        this.__selected.set(e)
    }

    get unSelected() {
        return this.__unSelected.get()
    }

    set unSelected(e) {
        this.__unSelected.set(e)
    }

    get copySelected() {
        return this.__copySelected.get()
    }

    set copySelected(e) {
        this.__copySelected.set(e)
    }

    get copyUnSelected() {
        return this.__copyUnSelected.get()
    }

    set copyUnSelected(e) {
        this.__copyUnSelected.set(e)
    }

    get content() {
        return this.__content.get()
    }

    set content(e) {
        this.__content.set(e)
    }

    get colNum() {
        return this.__colNum.get()
    }

    set colNum(e) {
        this.__colNum.set(e)
    }

    get gridComState() {
        return this.__gridComState.get()
    }

    set gridComState(e) {
        this.__gridComState.set(e)
    }

    get areaWidth() {
        return this.__areaWidth.get()
    }

    set areaWidth(e) {
        this.__areaWidth.set(e)
    }

    get blockWidth() {
        return this.__blockWidth.get()
    }

    set blockWidth(e) {
        this.__blockWidth.set(e)
    }

    get blockHeight() {
        return this.__blockHeight.get()
    }

    set blockHeight(e) {
        this.__blockHeight.set(e)
    }

    get longScale20() {
        return this.__longScale20.get()
    }

    set longScale20(e) {
        this.__longScale20.set(e)
    }

    get longScale09() {
        return this.__longScale09.get()
    }

    set longScale09(e) {
        this.__longScale09.set(e)
    }

    get isStartDrag() {
        return this.__isStartDrag.get()
    }

    set isStartDrag(e) {
        this.__isStartDrag.set(e)
    }

    get dragNextID() {
        return this.__dragNextID.get()
    }

    set dragNextID(e) {
        this.__dragNextID.set(e)
    }

    get insterIndex() {
        return this.__insterIndex.get()
    }

    set insterIndex(e) {
        this.__insterIndex.set(e)
    }

    get editGridDataLength() {
        return this.__editGridDataLength.get()
    }

    set editGridDataLength(e) {
        this.__editGridDataLength.set(e)
    }

    get touchDown() {
        return this.__touchDown.get()
    }

    set touchDown(e) {
        this.__touchDown.set(e)
    }

    get touchDownBg() {
        return this.__touchDownBg.get()
    }

    set touchDownBg(e) {
        this.__touchDownBg.set(e)
    }

    get isTouchDown() {
        return this.__isTouchDown.get()
    }

    set isTouchDown(e) {
        this.__isTouchDown.set(e)
    }

    get startX() {
        return this.__startX.get()
    }

    set startX(e) {
        this.__startX.set(e)
    }

    get startY() {
        return this.__startY.get()
    }

    set startY(e) {
        this.__startY.set(e)
    }

    get endX() {
        return this.__endX.get()
    }

    set endX(e) {
        this.__endX.set(e)
    }

    get endY() {
        return this.__endY.get()
    }

    set endY(e) {
        this.__endY.set(e)
    }

    get unSelectedIndex() {
        return this.__unSelectedIndex.get()
    }

    set unSelectedIndex(e) {
        this.__unSelectedIndex.set(e)
    }

    get isClickClostBtn() {
        return this.__isClickClostBtn.get()
    }

    set isClickClostBtn(e) {
        this.__isClickClostBtn.set(e)
    }

    get selectedIndex() {
        return this.__selectedIndex.get()
    }

    set selectedIndex(e) {
        this.__selectedIndex.set(e)
    }

    get arraySelectIsChange() {
        return this.__arraySelectIsChange.get()
    }

    set arraySelectIsChange(e) {
        this.__arraySelectIsChange.set(e)
    }

    get isClickAddBtn() {
        return this.__isClickAddBtn.get()
    }

    set isClickAddBtn(e) {
        this.__isClickAddBtn.set(e)
    }

    get arrayUnSelectIsChange() {
        return this.__arrayUnSelectIsChange.get()
    }

    set arrayUnSelectIsChange(e) {
        this.__arrayUnSelectIsChange.set(e)
    }

    get gridHeight() {
        return this.__gridHeight.get()
    }

    set gridHeight(e) {
        this.__gridHeight.set(e)
    }

    get isClickRemoveBtn() {
        return this.__isClickRemoveBtn.get()
    }

    set isClickRemoveBtn(e) {
        this.__isClickRemoveBtn.set(e)
    }

    get isVibrationDone() {
        return this.__isVibrationDone.get()
    }

    set isVibrationDone(e) {
        this.__isVibrationDone.set(e)
    }

    setInitiallyProvidedValue(e) {
        void 0 !== e.selected && (this.selected = e.selected);
        void 0 !== e.unSelected && (this.unSelected = e.unSelected);
        void 0 !== e.copySelected && (this.copySelected = e.copySelected);
        void 0 !== e.copyUnSelected && (this.copyUnSelected = e.copyUnSelected);
        void 0 !== e.content && (this.content = e.content);
        void 0 !== e.colNum && (this.colNum = e.colNum);
        void 0 !== e.gridComState && (this.gridComState = e.gridComState);
        void 0 !== e.areaWidth && (this.areaWidth = e.areaWidth);
        void 0 !== e.blockWidth && (this.blockWidth = e.blockWidth);
        void 0 !== e.blockHeight && (this.blockHeight = e.blockHeight);
        void 0 !== e.longScale20 && (this.longScale20 = e.longScale20);
        void 0 !== e.longScale09 && (this.longScale09 = e.longScale09);
        void 0 !== e.isStartDrag && (this.isStartDrag = e.isStartDrag);
        void 0 !== e.dragNextID && (this.dragNextID = e.dragNextID);
        void 0 !== e.insterIndex && (this.insterIndex = e.insterIndex);
        void 0 !== e.editGridDataLength && (this.editGridDataLength = e.editGridDataLength);
        void 0 !== e.touchDown && (this.touchDown = e.touchDown);
        void 0 !== e.touchDownBg && (this.touchDownBg = e.touchDownBg);
        void 0 !== e.isTouchDown && (this.isTouchDown = e.isTouchDown);
        void 0 !== e.startX && (this.startX = e.startX);
        void 0 !== e.startY && (this.startY = e.startY);
        void 0 !== e.endX && (this.endX = e.endX);
        void 0 !== e.endY && (this.endY = e.endY);
        void 0 !== e.unSelectedIndex && (this.unSelectedIndex = e.unSelectedIndex);
        void 0 !== e.isClickClostBtn && (this.isClickClostBtn = e.isClickClostBtn);
        void 0 !== e.selectedIndex && (this.selectedIndex = e.selectedIndex);
        void 0 !== e.arraySelectIsChange && (this.arraySelectIsChange = e.arraySelectIsChange);
        void 0 !== e.isClickAddBtn && (this.isClickAddBtn = e.isClickAddBtn);
        void 0 !== e.arrayUnSelectIsChange && (this.arrayUnSelectIsChange = e.arrayUnSelectIsChange);
        void 0 !== e.gridHeight && (this.gridHeight = e.gridHeight);
        void 0 !== e.isClickRemoveBtn && (this.isClickRemoveBtn = e.isClickRemoveBtn);
        void 0 !== e.isVibrationDone && (this.isVibrationDone = e.isVibrationDone);
        void 0 !== e.scroller && (this.scroller = e.scroller)
    }

    updateStateVars(e) {
    }

    purgeVariableDependenciesOnElmtId(e) {
        this.__options.purgeDependencyOnElmtId(e);
        this.__dataList.purgeDependencyOnElmtId(e);
        this.__selected.purgeDependencyOnElmtId(e);
        this.__unSelected.purgeDependencyOnElmtId(e);
        this.__copySelected.purgeDependencyOnElmtId(e);
        this.__copyUnSelected.purgeDependencyOnElmtId(e);
        this.__content.purgeDependencyOnElmtId(e);
        this.__colNum.purgeDependencyOnElmtId(e);
        this.__gridComState.purgeDependencyOnElmtId(e);
        this.__areaWidth.purgeDependencyOnElmtId(e);
        this.__blockWidth.purgeDependencyOnElmtId(e);
        this.__blockHeight.purgeDependencyOnElmtId(e);
        this.__longScale20.purgeDependencyOnElmtId(e);
        this.__longScale09.purgeDependencyOnElmtId(e);
        this.__isStartDrag.purgeDependencyOnElmtId(e);
        this.__dragNextID.purgeDependencyOnElmtId(e);
        this.__insterIndex.purgeDependencyOnElmtId(e);
        this.__editGridDataLength.purgeDependencyOnElmtId(e);
        this.__touchDown.purgeDependencyOnElmtId(e);
        this.__touchDownBg.purgeDependencyOnElmtId(e);
        this.__isTouchDown.purgeDependencyOnElmtId(e);
        this.__startX.purgeDependencyOnElmtId(e);
        this.__startY.purgeDependencyOnElmtId(e);
        this.__endX.purgeDependencyOnElmtId(e);
        this.__endY.purgeDependencyOnElmtId(e);
        this.__unSelectedIndex.purgeDependencyOnElmtId(e);
        this.__isClickClostBtn.purgeDependencyOnElmtId(e);
        this.__selectedIndex.purgeDependencyOnElmtId(e);
        this.__arraySelectIsChange.purgeDependencyOnElmtId(e);
        this.__isClickAddBtn.purgeDependencyOnElmtId(e);
        this.__arrayUnSelectIsChange.purgeDependencyOnElmtId(e);
        this.__gridHeight.purgeDependencyOnElmtId(e);
        this.__isClickRemoveBtn.purgeDependencyOnElmtId(e);
        this.__isVibrationDone.purgeDependencyOnElmtId(e)
    }

    aboutToBeDeleted() {
        this.__options.aboutToBeDeleted();
        this.__dataList.aboutToBeDeleted();
        this.__selected.aboutToBeDeleted();
        this.__unSelected.aboutToBeDeleted();
        this.__copySelected.aboutToBeDeleted();
        this.__copyUnSelected.aboutToBeDeleted();
        this.__content.aboutToBeDeleted();
        this.__colNum.aboutToBeDeleted();
        this.__gridComState.aboutToBeDeleted();
        this.__areaWidth.aboutToBeDeleted();
        this.__blockWidth.aboutToBeDeleted();
        this.__blockHeight.aboutToBeDeleted();
        this.__longScale20.aboutToBeDeleted();
        this.__longScale09.aboutToBeDeleted();
        this.__isStartDrag.aboutToBeDeleted();
        this.__dragNextID.aboutToBeDeleted();
        this.__insterIndex.aboutToBeDeleted();
        this.__editGridDataLength.aboutToBeDeleted();
        this.__touchDown.aboutToBeDeleted();
        this.__touchDownBg.aboutToBeDeleted();
        this.__isTouchDown.aboutToBeDeleted();
        this.__startX.aboutToBeDeleted();
        this.__startY.aboutToBeDeleted();
        this.__endX.aboutToBeDeleted();
        this.__endY.aboutToBeDeleted();
        this.__unSelectedIndex.aboutToBeDeleted();
        this.__isClickClostBtn.aboutToBeDeleted();
        this.__selectedIndex.aboutToBeDeleted();
        this.__arraySelectIsChange.aboutToBeDeleted();
        this.__isClickAddBtn.aboutToBeDeleted();
        this.__arrayUnSelectIsChange.aboutToBeDeleted();
        this.__gridHeight.aboutToBeDeleted();
        this.__isClickRemoveBtn.aboutToBeDeleted();
        this.__isVibrationDone.aboutToBeDeleted();
        SubscriberManager.Get().delete(this.id__());
        this.aboutToBeDeletedInternal()
    }

    onBackPress() {
        if (this.gridComState) {
            Context.animateTo({ duration: 500 }, (() => {
                this.gridComState = !1
            }));
            this.isClickClostBtn = !0;
            this.selected = this.copySelected;
            this.unSelected = this.copyUnSelected
        } else {
            router.back();
            this.isClickClostBtn = !1
        }
    }

    frSize() {
        let e = "1fr 1fr 1fr 1fr";
        this.options.type === GridEditType.imageText && (e = "1fr 1fr 1fr");
        return e
    }

    changeData(e, t, i) {
        return e.map(((e, o) => {
            e.state = t;
            e.sort = i + o;
            return e
        }))
    }

    getBlockWidth() {
        return (this.areaWidth - 36 - 48) / 4
    }

    getImageBlockWidth() {
        const e = (this.areaWidth - 36 - 32) / 3;
        return Math.trunc(e)
    }

    getEditItemGridCoord(e, t) {
        const i = e.length;
        const o = this.colNum;
        const s = Math.trunc(i % o);
        const r = Math.trunc(t % o);
        const c = s;
        let n = Math.abs(c - r) * (this.blockWidth + 16);
        c < r && (n = -n);
        c === r && (n = 0);
        let a = 0;
        let d = Math.trunc(t / this.colNum);
        if (0 === s) if (0 === d) {
            a = (0 === d ? 1 : d) * (this.blockHeight + 16) + 41
        } else a = (d + 1) * (this.blockHeight - 25) - 41; else a = (d + 1) * (this.blockHeight - 16) + 41;
        return { x: n, y: a }
    }

    getAddItemGridCoord(e, t) {
        const i = e.length;
        const o = this.colNum;
        const s = Math.trunc(i % o);
        const r = Math.trunc(t % o);
        const c = s;
        let n = Math.abs(c - r) * (this.blockWidth + 16);
        c < r && (n = -n);
        c === r && (n = 0);
        let a = 0;
        let d = Math.trunc(t / this.colNum);
        const h = i % o == 0 ? 0 : 1;
        let l = Math.trunc(i / this.colNum) + h;
        const p = this.selected.length;
        const g = p % o == 0 ? 0 : 1;
        let S = Math.trunc(p / this.colNum) + g;
        console.log("=========getAddItemGridCoord========>", s, d);
        a = 0 === s ? 0 === d ? (l + (S - d - 1)) * (this.blockHeight + 25) + 46 : this.options.type === GridEditType.imageText ? (l + (S - d)) * (this.blockHeight - 25) - 46 : (l + (S - d) + 1) * (this.blockHeight + 25) - 46 : (l - 1 + (S - d)) * (this.blockHeight - 16) + 46;
        return { x: n, y: a }
    }

    getCoveringGridCoord(e, t, i) {
        const o = e.length;
        let s = 0;
        let r = 0;
        if (t > i) if (i === o - 1) {
            s = 0;
            r = 0
        } else if (2 !== this.arraySelectIsChange) if (t % this.colNum == 0) {
            s = (this.blockWidth + 16) * (this.colNum - 1);
            r = 18 - this.blockHeight
        } else {
            s = -this.blockWidth;
            r = 0
        }
        return { x: s, y: r }
    }

    onDragMoveEvent(e, t, i) {
        var o;
        this.longScale09 = .95;
        if (!this.gridComState || e.x < this.blockWidth / 3 || e.y < this.blockHeight / 3) return;
        let s = i;
        i < 0 && (s = this.selected.length - 1);
        this.insterIndex = i;
        this.dragNextID = null === (o = this.selected[i]) || void 0 === o ? void 0 : o.id
    }

    deleteClick(e) {
        this.isClickRemoveBtn = !0;
        this.arraySelectIsChange = 1;
        let t = 0;
        this.selected.forEach(((i, o) => {
            i.id === e.id && (t = o)
        }));
        this.selectedIndex = t;
        const i = this.getAddItemGridCoord(this.unSelected, t);
        this.startX = i.x;
        this.startY = i.y;
        setTimeout((() => {
            this.arraySelectIsChange = 2;
            this.selected.splice(t, 1);
            this.unSelected.push(e);
            this.startX = 0;
            this.startY = 0;
            this.editGridDataLength = this.editGridDataLength - 1;
            this.isClickRemoveBtn = !1
        }), 500)
    }

    geyCoodXY(e) {
        const t = this.colNum;
        let i = 0;
        let o = 0;
        if (-1 != this.insterIndex) {
            if (e >= this.insterIndex) if (Math.trunc(e % t) === t - 1) if (this.options.type === GridEditType.imageText) {
                i = i - this.blockWidth * (t - 1) - 16 * (t - 1) - 3;
                o = o + this.blockHeight - 16 - 4
            } else {
                i = i - this.blockWidth * (t - 1) - 16 * (t - 1) - 3;
                o = o + this.blockHeight + 16 - 4
            } else i = i + this.blockWidth + 16 + 1.5;
            if (!this.isStartDrag) {
                i = 0;
                o = 0
            }
        }
        return { x: i, y: o }
    }

    getGridNum(e, t) {
        let i = e.length;
        let o = 0;
        i < this.colNum && (o = 1);
        if (t) {
            0 !== Math.trunc(i % this.colNum) && this.editGridDataLength === i && (o = 1);
            this.isStartDrag && (o = 1)
        } else 0 !== Math.trunc(i % this.colNum) && (o = 1);
        return o
    }

    getGridHeight(e, t) {
        let i = 0;
        let o = e.length;
        let s = e;
        let r = 0;
        if (t) {
            this.isClickClostBtn && (s = this.copySelected);
            1 === this.arrayUnSelectIsChange && (r = 1)
        }
        const c = Math.trunc(o / this.colNum) + this.getGridNum(s, t) + r;
        i = this.options.type === GridEditType.imageText ? (this.blockHeight - 16) * c : (this.blockHeight + 16) * c + 8;
        0 === o && (i = 0);
        t && (this.gridHeight = i);
        return i
    }

    getXY(e, t, i) {
        let o = 0;
        let s = 0;
        if (this.isStartDrag) {
            o = this.geyCoodXY(t).x;
            s = this.geyCoodXY(t).y
        } else if (this.isClickRemoveBtn) if (t === this.selectedIndex) {
            o = this.startX;
            s = this.startY
        } else {
            o = this.getCoveringGridCoord(e, t, i).x;
            s = this.getCoveringGridCoord(e, t, i).y
        } else {
            o = 0;
            s = 0
        }
        return { x: o, y: s }
    }

    getCoveringGridCoordBottom(e, t, i) {
        const o = e.length;
        let s = 0;
        let r = 0;
        if (t > i) if (i === o - 1) {
            s = 0;
            r = 0
        } else if (2 !== this.arrayUnSelectIsChange) if (t % this.colNum == 0) {
            s = (this.blockWidth + 16) * (this.colNum - 1);
            r = 18 - this.blockHeight
        } else {
            s = -this.blockWidth;
            r = 0
        }
        return { x: s, y: r }
    }

    getUnSelectXY(e, t, i) {
        let o = 0;
        let s = 0;
        if (this.isClickAddBtn) if (t === this.unSelectedIndex) {
            o = this.endX;
            s = -this.endY
        } else {
            o = this.getCoveringGridCoordBottom(e, t, i).x;
            s = this.getCoveringGridCoordBottom(e, t, i).y
        }
        return { x: o, y: s }
    }

    pixelMapBuilder(e = null) {
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Stack.create();
            Stack.padding({ top: this.options.type === GridEditType.imageText ? 12 : 6, right: 6 });
            t || Stack.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            If.create();
            this.options.type === GridEditType.imageText ? this.ifElseBranchUpdateFunction(0, (() => {
                this.observeComponentCreation(((e, t) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                    Stack.create();
                    Stack.height(((this.options.imageSize || 56) + 46) * this.longScale20);
                    t || Stack.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                this.imageTextBuilder.bind(this)(ObservedObject.GetRawObject(this.content), "delete", "pixe");
                Stack.pop()
            })) : this.ifElseBranchUpdateFunction(1, (() => {
                this.observeComponentCreation(((e, t) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                    Stack.create();
                    Stack.height(28 * this.longScale20);
                    t || Stack.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                this.observeComponentCreation(((e, t) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                    Text.create(this.content.text);
                    __Text__blockTextStyle(this.blockWidth);
                    Text.fontSize(14 * this.longScale20);
                    Text.width(this.blockWidth * this.longScale20);
                    Text.height(28 * this.longScale20);
                    t || Text.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                Text.pop();
                this.observeComponentCreation(((e, t) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                    Image.create({
                        id: -1,
                        type: 2e4,
                        params: ["app.media.remove"],
                        bundleName: "",
                        moduleName: ""
                    });
                    Image.fillColor({
                        id: -1,
                        type: 10001,
                        params: ["sys.color.ohos_id_color_secondary"],
                        bundleName: "",
                        moduleName: ""
                    });
                    Image.width(24 * this.longScale20);
                    Image.height(24 * this.longScale20);
                    Image.position({ x: this.blockWidth * this.longScale20 - 32, y: -6 });
                    t || Image.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                Stack.pop()
            }));
            t || If.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        If.pop();
        Stack.pop()
    }

    headerTitleBuilder(e = "default", t, i = null) {
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Stack.create();
            t || Stack.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Flex.create({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center });
            Flex.height(42);
            Flex.margin({ left: 12, right: 12, top: 12 });
            t || Flex.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Row.create();
            t || Row.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((t, i) => {
            ViewStackProcessor.StartGetAccessRecordingFor(t);
            Stack.create();
            Stack.margin({ right: 8 });
            Stack.padding(8);
            Stack.borderRadius(50);
            Stack.backgroundColor({
                id: -1,
                type: 10001,
                params: ["sys.color.ohos_id_color_button_normal"],
                bundleName: "",
                moduleName: ""
            });
            Stack.onClick((() => {
                this.longScale20 = 1;
                if ("default" === e) {
                    router.back();
                    this.isClickClostBtn = !1
                } else {
                    Context.animateTo({ duration: 500 }, (() => {
                        this.gridComState = !1
                    }));
                    this.editGridDataLength = Math.trunc(this.selected.length);
                    this.isClickClostBtn = !0;
                    const e = this.changeData(ObservedObject.GetRawObject(this.copySelected), StateType.select, 0);
                    const t = this.changeData(ObservedObject.GetRawObject(this.copyUnSelected), StateType.select, this.selected.length);
                    setTimeout((() => {
                        this.selected = this.copySelected;
                        this.editGridDataLength = this.copySelected.length;
                        this.unSelected = this.copyUnSelected
                    }), 100);
                    this.dataList = [...e, ...t]
                }
            }));
            i || Stack.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((t, i) => {
            ViewStackProcessor.StartGetAccessRecordingFor(t);
            Image.create("edit" === e ? {
                id: -1,
                type: 2e4,
                params: ["app.media.ic_public_cancel"],
                bundleName: "",
                moduleName: ""
            } : {
                id: -1,
                type: 2e4,
                params: ["app.media.ic_public_back"],
                bundleName: "",
                moduleName: ""
            });
            Image.width(16);
            Image.fillColor({
                id: -1,
                type: 10001,
                params: ["sys.color.ohos_id_color_text_secondary"],
                bundleName: "",
                moduleName: ""
            });
            i || Image.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Stack.pop();
        this.observeComponentCreation(((e, i) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Text.create(t || "编辑");
            Text.fontSize(14);
            i || Text.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Text.pop();
        Row.pop();
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Row.create();
            t || Row.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((t, i) => {
            ViewStackProcessor.StartGetAccessRecordingFor(t);
            Stack.create();
            Stack.padding(8);
            Stack.borderRadius(50);
            Stack.backgroundColor({
                id: -1,
                type: 10001,
                params: ["sys.color.ohos_id_color_button_normal"],
                bundleName: "",
                moduleName: ""
            });
            Stack.onClick((() => {
                this.isClickClostBtn = !1;
                this.longScale20 = 1;
                this.editGridDataLength = Math.trunc(this.selected.length);
                "default" === e ? Context.animateTo({ duration: 500 }, (() => {
                    this.gridComState = !0
                })) : Context.animateTo({ duration: 500 }, (() => {
                    this.gridComState = !1
                }));
                this.copySelected = JSON.parse(JSON.stringify(ObservedObject.GetRawObject(this.selected)));
                this.copyUnSelected = JSON.parse(JSON.stringify(ObservedObject.GetRawObject(this.unSelected)));
                const t = this.changeData(ObservedObject.GetRawObject(this.selected), StateType.select, 0);
                const i = this.changeData(ObservedObject.GetRawObject(this.unSelected), StateType.select, this.selected.length);
                this.dataList = [...t, ...i]
            }));
            i || Stack.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((t, i) => {
            ViewStackProcessor.StartGetAccessRecordingFor(t);
            Image.create("edit" === e ? {
                id: -1,
                type: 2e4,
                params: ["app.media.ic_public_ok"],
                bundleName: "",
                moduleName: ""
            } : {
                id: -1,
                type: 2e4,
                params: ["app.media.ic_public_edit"],
                bundleName: "",
                moduleName: ""
            });
            Image.width(16);
            Image.fillColor({
                id: -1,
                type: 10001,
                params: ["sys.color.ohos_id_color_text_secondary"],
                bundleName: "",
                moduleName: ""
            });
            i || Image.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Stack.pop();
        Row.pop();
        Flex.pop();
        Stack.pop()
    }

    imageTextBuilder(e, t, i, o = null) {
        this.observeComponentCreation(((t, i) => {
            ViewStackProcessor.StartGetAccessRecordingFor(t);
            Flex.create({
                direction: FlexDirection.Column,
                justifyContent: FlexAlign.Center,
                alignItems: ItemAlign.Center
            });
            Context.animation({ duration: 500 });
            Flex.backgroundColor(this.isTouchDown && e.id === this.content.id ? this.touchDown : "");
            Flex.colorBlend(this.isTouchDown && e.id === this.content.id ? this.touchDownBg : "");
            Context.animation(null);
            Flex.width(this.blockWidth);
            Flex.zIndex(999);
            Flex.padding({ top: 12, bottom: 8, left: 8, right: 8 });
            i || Flex.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((t, o) => {
            ViewStackProcessor.StartGetAccessRecordingFor(t);
            If.create();
            i || e.id === this.content.id ? this.ifElseBranchUpdateFunction(0, (() => {
                this.observeComponentCreation(((t, i) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(t);
                    Image.create(e.url || PUBLIC_DEFAULT_IMAGE);
                    Image.height((this.options.imageSize || 56) * (e.id === this.content.id ? 1 : this.longScale20));
                    Image.width((this.options.imageSize || 56) * this.longScale20);
                    i || Image.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                this.observeComponentCreation(((t, i) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(t);
                    Text.create(e.text);
                    Text.textAlign(TextAlign.Center);
                    Text.width(this.blockWidth * this.longScale20);
                    Text.padding({ top: 2, left: 12, right: 12 });
                    Text.maxLines(1);
                    Text.textOverflow({ overflow: TextOverflow.Ellipsis });
                    Text.textAlign(TextAlign.Center);
                    i || Text.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                Text.pop()
            })) : this.ifElseBranchUpdateFunction(1, (() => {
                this.observeComponentCreation(((t, i) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(t);
                    Image.create(e.url || PUBLIC_DEFAULT_IMAGE);
                    Image.height(this.options.imageSize || 56);
                    Image.width((this.options.imageSize || 56) * this.longScale09);
                    i || Image.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                this.observeComponentCreation(((t, i) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(t);
                    Text.create(e.text);
                    Text.textAlign(TextAlign.Center);
                    Text.width(this.blockWidth * (this.isStartDrag && e.id === this.dragNextID ? this.longScale09 : 1));
                    Text.padding({ top: 2, left: 12, right: 12 });
                    Text.maxLines(1);
                    Text.textOverflow({ overflow: TextOverflow.Ellipsis });
                    Text.textAlign(TextAlign.Center);
                    i || Text.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }));
                Text.pop()
            }));
            o || If.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        If.pop();
        this.observeComponentCreation(((i, o) => {
            ViewStackProcessor.StartGetAccessRecordingFor(i);
            If.create();
            "add" === t ? this.ifElseBranchUpdateFunction(0, (() => {
                this.observeComponentCreation(((t, i) => {
                    ViewStackProcessor.StartGetAccessRecordingFor(t);
                    Image.create({
                        id: -1,
                        type: 2e4,
                        params: ["app.media.add_image"],
                        bundleName: "",
                        moduleName: ""
                    });
                    Image.fillColor({
                        id: -1,
                        type: 10001,
                        params: ["sys.color.ohos_id_color_secondary"],
                        bundleName: "",
                        moduleName: ""
                    });
                    Image.width(24);
                    Image.height(24);
                    Image.position({ x: this.blockWidth - 22, y: -22 });
                    Image.onClick((() => {
                        const t = this.unSelected.findIndex((t => t.id === e.id));
                        this.editGridDataLength = Math.trunc(this.selected.length) + 1;
                        const i = this.getEditItemGridCoord(ObservedObject.GetRawObject(this.selected), t);
                        this.unSelectedIndex = t;
                        this.endX = i.x;
                        this.endY = i.y;
                        this.isClickAddBtn = !0;
                        this.arrayUnSelectIsChange = 1;
                        setTimeout((() => {
                            this.arrayUnSelectIsChange = 2;
                            this.selected.push(e);
                            this.unSelected.splice(t, 1);
                            this.endX = 0;
                            this.endY = 0;
                            this.isClickAddBtn = !1
                        }), 500)
                    }));
                    i || Image.pop();
                    ViewStackProcessor.StopGetAccessRecording()
                }))
            })) : If.branchId(1);
            o || If.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        If.pop();
        this.observeComponentCreation(((o, s) => {
            ViewStackProcessor.StartGetAccessRecordingFor(o);
            Image.create({
                id: -1,
                type: 2e4,
                params: ["app.media.remove"],
                bundleName: "",
                moduleName: ""
            });
            Context.animation({ duration: 500 });
            Image.fillColor({
                id: -1,
                type: 10001,
                params: ["sys.color.ohos_id_color_secondary"],
                bundleName: "",
                moduleName: ""
            });
            Image.visibility("delete" === t && this.gridComState ? 0 : 1);
            Image.width(i && e.id === this.content.id ? 24 * this.longScale20 : 24);
            Image.height(i && e.id === this.content.id ? 24 * this.longScale20 : 24);
            Context.animation(null);
            Image.opacity("delete" === t && this.gridComState ? 1 : 0);
            Image.position({ x: i && e.id === this.content.id ? this.blockWidth - 32 : this.blockWidth - 22, y: -22 });
            Image.onClick((() => this.deleteClick(e)));
            s || Image.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Flex.pop()
    }

    textBlockBuilder(e, t, i = null) {
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Stack.create();
            Stack.height(28);
            t || Stack.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((i, o) => {
            ViewStackProcessor.StartGetAccessRecordingFor(i);
            Text.create(e.text);
            __Text__blockTextStyle(this.blockWidth);
            Text.width("delete" === t && this.gridComState ? this.blockWidth * (this.isStartDrag && e.id === this.dragNextID ? this.longScale09 : 1) - 5 : this.blockWidth);
            Text.padding({ top: 2, left: 12, right: 12 });
            Text.maxLines(1);
            Text.textOverflow({ overflow: TextOverflow.Ellipsis });
            Text.textAlign(TextAlign.Center);
            Text.backgroundColor(this.isTouchDown && e.id === this.content.id ? this.touchDown : {
                id: -1,
                type: 10001,
                params: ["sys.color.ohos_id_color_button_normal"],
                bundleName: "",
                moduleName: ""
            });
            Text.colorBlend(this.isTouchDown && e.id === this.content.id ? this.touchDownBg : "");
            o || Text.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Text.pop();
        this.observeComponentCreation(((i, o) => {
            ViewStackProcessor.StartGetAccessRecordingFor(i);
            Image.create({
                id: -1,
                type: 2e4,
                params: ["app.media.remove"],
                bundleName: "",
                moduleName: ""
            });
            Context.animation({ duration: 500, curve: Curve.Linear, iterations: 1, playMode: PlayMode.Normal });
            Image.opacity("delete" === t && this.gridComState ? 1 : 0);
            Image.visibility("delete" === t && this.gridComState ? 0 : 1);
            Image.fillColor({
                id: -1,
                type: 10001,
                params: ["sys.color.ohos_id_color_secondary"],
                bundleName: "",
                moduleName: ""
            });
            Image.width(this.isStartDrag && e.id === this.content.id ? 24 * this.longScale20 : 24);
            Image.position({
                x: "delete" === t && this.gridComState ? this.blockWidth - 21 : this.blockWidth - 16,
                y: -6
            });
            Context.animation(null);
            Image.onClick((() => this.deleteClick(e)));
            o || Image.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Stack.pop()
    }

    addTagBuilder(e = null) {
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Grid.create();
            Grid.columnsTemplate(this.frSize());
            Grid.padding({ top: 8, left: 8, right: 8 });
            Grid.clip(!1);
            Grid.height(this.getGridHeight(ObservedObject.GetRawObject(this.unSelected)) + 120);
            t || Grid.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            ForEach.create();
            this.forEachUpdateFunction(e, this.unSelected, ((e, t) => {
                const i = e;
                {
                    const e = !0 === Grid.willUseProxy();
                    const o = (i, o) => {
                        ViewStackProcessor.StartGetAccessRecordingFor(i);
                        GridItem.create(c, e);
                        Context.animation({
                            duration: 500,
                            curve: Curve.Linear,
                            iterations: 1,
                            playMode: PlayMode.Normal
                        });
                        GridItem.translate({
                            x: this.getUnSelectXY(ObservedObject.GetRawObject(this.unSelected), t, this.unSelectedIndex).x,
                            y: this.getUnSelectXY(ObservedObject.GetRawObject(this.unSelected), t, this.unSelectedIndex).y
                        });
                        Context.animation(null);
                        o || GridItem.pop();
                        ViewStackProcessor.StopGetAccessRecording()
                    };
                    const s = () => {
                        this.observeComponentCreation(o);
                        GridItem.pop()
                    };
                    const r = () => {
                        this.observeComponentCreation(o);
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            Stack.create();
                            Stack.margin({ top: 2, bottom: 16 });
                            Stack.onTouch((e => {
                                if (e.type === TouchType.Down) {
                                    this.content = i;
                                    this.isTouchDown = !0
                                }
                                e.type === TouchType.Up && (this.isTouchDown = !1)
                            }));
                            Gesture.create(GesturePriority.Low);
                            LongPressGesture.create({ repeat: !0 });
                            LongPressGesture.onAction((e => {
                                this.gridComState || Context.animateTo({ duration: 500 }, (() => {
                                    this.gridComState = !0
                                }))
                            }));
                            LongPressGesture.pop();
                            Gesture.pop();
                            Stack.onClick((() => {
                                const e = this.unSelected.findIndex((e => e.id === i.id));
                                this.editGridDataLength = Math.trunc(this.selected.length) + 1;
                                const t = this.getEditItemGridCoord(ObservedObject.GetRawObject(this.selected), e);
                                this.unSelectedIndex = e;
                                this.endX = t.x;
                                this.endY = t.y;
                                this.isClickAddBtn = !0;
                                this.arrayUnSelectIsChange = 1;
                                setTimeout((() => {
                                    this.arrayUnSelectIsChange = 2;
                                    this.selected.push(i);
                                    this.unSelected.splice(e, 1);
                                    this.endX = 0;
                                    this.endY = 0;
                                    this.isClickAddBtn = !1
                                }), 500)
                            }));
                            t || Stack.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            If.create();
                            this.options.type === GridEditType.imageText ? this.ifElseBranchUpdateFunction(0, (() => {
                                this.imageTextBuilder.bind(this)(i, "add")
                            })) : this.ifElseBranchUpdateFunction(1, (() => {
                                this.observeComponentCreation(((e, t) => {
                                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                                    Flex.create({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center });
                                    Flex.backgroundColor(this.isTouchDown && i.id === this.content.id ? this.touchDown : {
                                        id: -1,
                                        type: 10001,
                                        params: ["sys.color.ohos_id_color_button_normal"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Flex.borderRadius(50);
                                    Flex.height(28);
                                    Flex.width(this.blockWidth);
                                    Flex.padding({ top: 8, bottom: 8, left: 12, right: 12 });
                                    t || Flex.pop();
                                    ViewStackProcessor.StopGetAccessRecording()
                                }));
                                this.observeComponentCreation(((e, t) => {
                                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                                    Image.create({
                                        id: -1,
                                        type: 2e4,
                                        params: ["app.media.add"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Image.fillColor({
                                        id: -1,
                                        type: 10001,
                                        params: ["sys.color.ohos_id_color_text_secondary"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Image.width(16);
                                    Image.margin({ right: 4 });
                                    t || Image.pop();
                                    ViewStackProcessor.StopGetAccessRecording()
                                }));
                                this.observeComponentCreation(((e, t) => {
                                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                                    Text.create(i.text);
                                    Text.fontSize({
                                        id: -1,
                                        type: 10002,
                                        params: ["sys.float.ohos_id_text_size_button3"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Text.width(this.blockWidth - 24);
                                    Text.maxLines(1);
                                    Text.textOverflow({ overflow: TextOverflow.Ellipsis });
                                    t || Text.pop();
                                    ViewStackProcessor.StopGetAccessRecording()
                                }));
                                Text.pop();
                                Flex.pop()
                            }));
                            t || If.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        If.pop();
                        Stack.pop();
                        GridItem.pop()
                    };
                    const c = (e, t) => {
                        o(e, t);
                        this.updateFuncByElmtId.set(e, o);
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            Stack.create();
                            Stack.margin({ top: 2, bottom: 16 });
                            Stack.onTouch((e => {
                                if (e.type === TouchType.Down) {
                                    this.content = i;
                                    this.isTouchDown = !0
                                }
                                e.type === TouchType.Up && (this.isTouchDown = !1)
                            }));
                            Gesture.create(GesturePriority.Low);
                            LongPressGesture.create({ repeat: !0 });
                            LongPressGesture.onAction((e => {
                                this.gridComState || Context.animateTo({ duration: 500 }, (() => {
                                    this.gridComState = !0
                                }))
                            }));
                            LongPressGesture.pop();
                            Gesture.pop();
                            Stack.onClick((() => {
                                const e = this.unSelected.findIndex((e => e.id === i.id));
                                this.editGridDataLength = Math.trunc(this.selected.length) + 1;
                                const t = this.getEditItemGridCoord(ObservedObject.GetRawObject(this.selected), e);
                                this.unSelectedIndex = e;
                                this.endX = t.x;
                                this.endY = t.y;
                                this.isClickAddBtn = !0;
                                this.arrayUnSelectIsChange = 1;
                                setTimeout((() => {
                                    this.arrayUnSelectIsChange = 2;
                                    this.selected.push(i);
                                    this.unSelected.splice(e, 1);
                                    this.endX = 0;
                                    this.endY = 0;
                                    this.isClickAddBtn = !1
                                }), 500)
                            }));
                            t || Stack.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            If.create();
                            this.options.type === GridEditType.imageText ? this.ifElseBranchUpdateFunction(0, (() => {
                                this.imageTextBuilder.bind(this)(i, "add")
                            })) : this.ifElseBranchUpdateFunction(1, (() => {
                                this.observeComponentCreation(((e, t) => {
                                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                                    Flex.create({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center });
                                    Flex.backgroundColor(this.isTouchDown && i.id === this.content.id ? this.touchDown : {
                                        id: -1,
                                        type: 10001,
                                        params: ["sys.color.ohos_id_color_button_normal"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Flex.borderRadius(50);
                                    Flex.height(28);
                                    Flex.width(this.blockWidth);
                                    Flex.padding({ top: 8, bottom: 8, left: 12, right: 12 });
                                    t || Flex.pop();
                                    ViewStackProcessor.StopGetAccessRecording()
                                }));
                                this.observeComponentCreation(((e, t) => {
                                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                                    Image.create({
                                        id: -1,
                                        type: 2e4,
                                        params: ["app.media.add"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Image.fillColor({
                                        id: -1,
                                        type: 10001,
                                        params: ["sys.color.ohos_id_color_text_secondary"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Image.width(16);
                                    Image.margin({ right: 4 });
                                    t || Image.pop();
                                    ViewStackProcessor.StopGetAccessRecording()
                                }));
                                this.observeComponentCreation(((e, t) => {
                                    ViewStackProcessor.StartGetAccessRecordingFor(e);
                                    Text.create(i.text);
                                    Text.fontSize({
                                        id: -1,
                                        type: 10002,
                                        params: ["sys.float.ohos_id_text_size_button3"],
                                        bundleName: "",
                                        moduleName: ""
                                    });
                                    Text.width(this.blockWidth - 24);
                                    Text.maxLines(1);
                                    Text.textOverflow({ overflow: TextOverflow.Ellipsis });
                                    t || Text.pop();
                                    ViewStackProcessor.StopGetAccessRecording()
                                }));
                                Text.pop();
                                Flex.pop()
                            }));
                            t || If.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        If.pop();
                        Stack.pop();
                        GridItem.pop()
                    };
                    e ? s() : r()
                }
            }), void 0,!0,!1);
            t || ForEach.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        ForEach.pop();
        Grid.pop()
    }

    editTagBuilder(e = null) {
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Grid.create();
            Gesture.create(GesturePriority.Parallel);
            LongPressGesture.create({ repeat: !0 });
            LongPressGesture.onAction((e => {
                if (this.gridComState) {
                    this.longScale20 = 1.2;
                    if (e.repeat && !this.isVibrationDone) try {
                        vibrator.startVibration({ type: "time", duration: 1e3 }, {
                            id: 0,
                            usage: "alarm"
                        }).then((() => {
                            this.isVibrationDone = !0
                        }))
                    } catch (e) {
                        this.isVibrationDone = !1;
                        console.info("不支持震动")
                    }
                } else Context.animateTo({ duration: 500 }, (() => {
                    this.gridComState = !0
                }))
            }));
            LongPressGesture.pop();
            Gesture.pop();
            Grid.clip(!1);
            Grid.editMode(this.gridComState);
            Grid.columnsTemplate(this.frSize());
            Grid.padding({ top: 8, left: 8, right: 8 });
            Grid.height(this.getGridHeight(ObservedObject.GetRawObject(this.selected), "edit"));
            Grid.onItemDragStart(((e, t) => {
                this.selectedIndex = -1;
                if (this.gridComState) {
                    this.isStartDrag = !0;
                    this.selected.splice(t, 1);
                    this.editGridDataLength = this.selected.length + 1;
                    return { builder: () => {
                        this.pixelMapBuilder.call(this)
                    } }
                }
            }));
            Grid.onItemDrop(((e, t, i, o) => {
                if (this.gridComState) {
                    this.isVibrationDone = !1;
                    this.longScale20 = 1;
                    this.longScale09 = 1;
                    this.isStartDrag = !1;
                    this.selected.splice(-1 !== i ? i : this.selected.length - 1, 0, ObservedObject.GetRawObject(this.content))
                }
            }));
            Grid.onItemDragMove(((e, t, i) => this.onDragMoveEvent(e, t, i)));
            t || Grid.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            ForEach.create();
            this.forEachUpdateFunction(e, this.selected, ((e, t) => {
                const i = e;
                {
                    const e = !0 === Grid.willUseProxy();
                    const o = (i, o) => {
                        ViewStackProcessor.StartGetAccessRecordingFor(i);
                        GridItem.create(c, e);
                        Context.animation({
                            duration: 500,
                            curve: Curve.Linear,
                            iterations: 1,
                            playMode: PlayMode.Normal
                        });
                        GridItem.translate({
                            x: this.getXY(ObservedObject.GetRawObject(this.selected), t, this.selectedIndex).x,
                            y: this.getXY(ObservedObject.GetRawObject(this.selected), t, this.selectedIndex).y
                        });
                        Context.animation(null);
                        o || GridItem.pop();
                        ViewStackProcessor.StopGetAccessRecording()
                    };
                    const s = () => {
                        this.observeComponentCreation(o);
                        GridItem.pop()
                    };
                    const r = () => {
                        this.observeComponentCreation(o);
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            Stack.create();
                            Stack.margin({ top: 2, bottom: 16 });
                            Stack.onTouch((e => {
                                if (this.gridComState) {
                                    if (e.type === TouchType.Down) {
                                        this.content = i;
                                        this.isTouchDown = !0
                                    }
                                    if (e.type === TouchType.Up) {
                                        this.isTouchDown = !1;
                                        this.longScale20 = 1;
                                        this.longScale09 = 1
                                    }
                                }
                            }));
                            t || Stack.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            If.create();
                            this.options.type === GridEditType.imageText ? this.ifElseBranchUpdateFunction(0, (() => {
                                this.imageTextBuilder.bind(this)(i, "delete")
                            })) : this.ifElseBranchUpdateFunction(1, (() => {
                                this.textBlockBuilder.bind(this)(i, "delete")
                            }));
                            t || If.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        If.pop();
                        Stack.pop();
                        GridItem.pop()
                    };
                    const c = (e, t) => {
                        o(e, t);
                        this.updateFuncByElmtId.set(e, o);
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            Stack.create();
                            Stack.margin({ top: 2, bottom: 16 });
                            Stack.onTouch((e => {
                                if (this.gridComState) {
                                    if (e.type === TouchType.Down) {
                                        this.content = i;
                                        this.isTouchDown = !0
                                    }
                                    if (e.type === TouchType.Up) {
                                        this.isTouchDown = !1;
                                        this.longScale20 = 1;
                                        this.longScale09 = 1
                                    }
                                }
                            }));
                            t || Stack.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        this.observeComponentCreation(((e, t) => {
                            ViewStackProcessor.StartGetAccessRecordingFor(e);
                            If.create();
                            this.options.type === GridEditType.imageText ? this.ifElseBranchUpdateFunction(0, (() => {
                                this.imageTextBuilder.bind(this)(i, "delete")
                            })) : this.ifElseBranchUpdateFunction(1, (() => {
                                this.textBlockBuilder.bind(this)(i, "delete")
                            }));
                            t || If.pop();
                            ViewStackProcessor.StopGetAccessRecording()
                        }));
                        If.pop();
                        Stack.pop();
                        GridItem.pop()
                    };
                    e ? s() : r()
                }
            }), void 0,!0,!1);
            t || ForEach.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        ForEach.pop();
        Grid.pop()
    }

    initialRender() {
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Column.create();
            Column.width("100%");
            Column.height("90%");
            t || Column.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            If.create();
            this.gridComState ? this.ifElseBranchUpdateFunction(0, (() => {
                this.headerTitleBuilder.bind(this)("edit", this.options.editTitle || "编辑")
            })) : this.ifElseBranchUpdateFunction(1, (() => {
                this.headerTitleBuilder.bind(this)("default", this.options.title || "频道")
            }));
            t || If.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        If.pop();
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Scroll.create(this.scroller);
            t || Scroll.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Column.create();
            Column.onAreaChange(((e, t) => {
                this.areaWidth = Math.trunc(Number(t.width));
                this.blockWidth = this.options.type === GridEditType.imageText ? this.getImageBlockWidth() : this.getBlockWidth()
            }));
            Column.width("100%");
            t || Column.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Text.create(this.options.secondaryTitleFirst || "长按拖动排序");
            __Text__subTitleTextStyle();
            t || Text.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Text.pop();
        this.editTagBuilder.bind(this)();
        this.observeComponentCreation(((e, t) => {
            ViewStackProcessor.StartGetAccessRecordingFor(e);
            Text.create(this.options.secondaryTitleSecond || "点击添加");
            __Text__subTitleTextStyle();
            t || Text.pop();
            ViewStackProcessor.StopGetAccessRecording()
        }));
        Text.pop();
        this.addTagBuilder.bind(this)();
        Column.pop();
        Scroll.pop();
        Column.pop()
    }

    rerender() {
        this.updateDirtyElements()
    }
}